package thread;

//面试题:start方法和run方法的区别：差别在于是是否在系统内部创建出线程
// start方法是会调用系统api创建出线程
//而run方法单纯描述了线程应该执行的内容(会在start创建好线程后自动被调用)
public class Demo7 {
    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            System.out.println("线程开始");
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println("线程结束");
        });

        t1.start();
        System .out.println(t1.isAlive());
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println(t1.isAlive());
    }
}
